package com.hiwhitley.himei.contract.presenter;

import com.hiwhitley.himei.contract.CommonFindContract;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by hiwhitley on 2016/9/28.
 */

public class CommonFindPresenter extends CommonFindContract.Presenter {

    private static final String TAG = "CommonFindPresenter";

    @Override
    public void loadCommonFind(String name, String strategy) {
        mRxManager.add(mModel.getCommonFinds(name, strategy)
                .subscribeOn(Schedulers.io())
                .map(findMoreInfo -> findMoreInfo.getItemList())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(
                        itemListEntities -> mView.showCommonFind(itemListEntities),
                        throwable -> {
                            mView.onInternetError();
                            mView.onRequestEnd();
                        }

                )
        );
    }

}
